package com.xiaozhou.config;

import com.xiaozhou.utils.CaptchaGenerator;
import com.xiaozhou.utils.IdWorker;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author : itheima
 * @date : 2022/9/19 17:35
 * @description : 定义公共的配置类
 */
@Configuration
public class CommonConfig {
    /**
     * 定义密码加密匹配器bean
     * @return
     */
    @Bean
    public static PasswordEncoder passwordEncoder(){
        return new BCryptPasswordEncoder();
    }


    /**
     * 配置 id ⽣成器bean
     */
    @Bean
    public IdWorker idWorker(){
        //基于运维⼈员对机房和机器的编号规划⾃⾏约定
        return new IdWorker(1l,2l);
    }

    /**
     * 验证码生成
     * */
    @Bean
    public CaptchaGenerator captchaGenerator(){
        return new CaptchaGenerator();
    }


}
